package com.vench.teddy.rabbitmq.config;

import com.vench.teddy.rabbitmq.constants.MQConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:vench
 * @Date:2024-09-10 22:42
 *
 * direct类型消息队列定义
 */
@Configuration
public class DirectConfig {

    @Bean
    DirectExchange directExchange(){
        return new DirectExchange(MQConstants.DIRECT_EXCHANGE_NAME, Boolean.TRUE, Boolean.FALSE);
    }

    @Bean
    Queue directQueue1(){
        return new Queue(MQConstants.DIRECT_QUEUE_NAME_1, Boolean.TRUE);
    }

    @Bean
    Queue directQueue2(){
        return new Queue(MQConstants.DIRECT_QUEUE_NAME_2, Boolean.TRUE);
    }

    @Bean
    Binding directBinding1(){
        return BindingBuilder.bind(directQueue1()).to(directExchange()).with(MQConstants.DIRECT_ROUTING_NAME);
    }

    @Bean
    Binding directBinding2(){
        return BindingBuilder.bind(directQueue2()).to(directExchange()).with(MQConstants.DIRECT_ROUTING_NAME);
    }

}
